package com.yunkaweilai.android.view.home;

import android.app.Activity;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.yunkaweilai.android.R;
import com.yunkaweilai.android.base.BaseApplication;
import com.yunkaweilai.android.model.AppRuleModel;
import com.yunkaweilai.android.model.CountMainBean;
import com.yunkaweilai.android.model.home.AppHomeModel;

import butterknife.BindView;
import butterknife.ButterKnife;


/**
 * Created by sunfusheng on 16/4/20.
 */
public class HeaderShopInfoView extends AbsHeaderView<CountMainBean.DataBean.InfoBean> {

    private final AppRuleModel.DataBean.InfoBean appRuleModel;
    @BindView(R.id.id_tv_turnover)
    TextView idTvTurnover;
    @BindView(R.id.id_tv_consumption_num)
    TextView idTvConsumptionNum;
    @BindView(R.id.id_tv_recharge_price)
    TextView idTvRechargePrice;
    @BindView(R.id.id_tv_member_add)
    TextView idTvMemberAdd;

    public HeaderShopInfoView(Activity context) {
        super(context);
        appRuleModel = BaseApplication.getAppRuleModel();
    }

    @Override
    protected void getView(CountMainBean.DataBean.InfoBean model, ListView listView) {
        View view = mInflate.inflate(R.layout.header_shop_layout, listView, false);
        ButterKnife.bind(this, view);
        listView.addHeaderView(view);
        initView(model);
    }

    private void initView(CountMainBean.DataBean.InfoBean model) {
        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("3")){
            idTvTurnover.setText(model.getToday_z_order_count()+"");
            idTvConsumptionNum.setText(model.getUse_coupon_number_count()+"");
            idTvRechargePrice.setText(model.getGoods_stock_count()+"");
            idTvMemberAdd.setText(model.getSms_count()+"");
        }else{
            idTvTurnover.setText("--");
            idTvConsumptionNum.setText("--");
            idTvRechargePrice.setText("--");
            idTvMemberAdd.setText("--");
        }

    }

    public void refresh(CountMainBean.DataBean.InfoBean model){
        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("3")){
            idTvTurnover.setText(model.getToday_z_order_count()+"");
            idTvConsumptionNum.setText(model.getUse_coupon_number_count()+"");
            idTvRechargePrice.setText(model.getGoods_stock_count()+"");
            idTvMemberAdd.setText(model.getSms_count()+"");
        }else{
            idTvTurnover.setText("--");
            idTvConsumptionNum.setText("--");
            idTvRechargePrice.setText("--");
            idTvMemberAdd.setText("--");
        }
    }

}
